import request from '@/utils/request'

// 获取指定商品详情
export const detail = (proid:string)=>{
  return request({
    url:'/pro/detail/'+proid
  })
}


// 指定商品加入购物车
export const add = (userid:string,proid:string,num:number)=>{
  return request({
    url:'/cart/add',
    method:'post',
    data:{
      userid,proid,num
    }
  })
}

// 获取购物车商品列表
export const cartlist = (userid:string)=>{
  return request({
    url:'/cart/list',
    method:'post',
    data:{
      userid
    }
  })
}
// 获取推荐商品列表
export const recommendlist = (count:number)=>{
  return request({
    url:'/pro/recommendlist',
    params:{
      count
    }
  })
}

// 修改指定商品数量
export const updatenum = (cartid:string,num:number)=>{
  return request({
    url:'/cart/updatenum',
    data:{
      cartid,num
    },
    method:'post'
  })
}

// 修改指定商品选中状态
export const selectone = (cartid:string,flag:boolean)=>{
  return request({
    url:"/cart/selectone",
    method:'post',
    data:{
      cartid,flag
    }
  })
}

// 修改所有商品选中状态
export const selectall = (userid:string,type:boolean)=>{
  return request({
    url:"/cart/selectall",
    method:"post",
    data:{
      userid,type
    }
  })
}

// 删除指定商品
export const deleteone = (cartid:string)=>{
  return request({
    url:"/cart/remove",
    method:"post",
    data:{
      cartid
    }
  })
}

// 添加订单接口
export const addorder = (userid:string)=>{
  return request({
    url:"/order/addOrder",
    method:"post",
    data:{
      userid
    }
  })
}